package org.metasketch.demo.project;

import java.util.List;

import javafx.scene.control.Tab;

import org.metasketch.demo.graphics.DEMODiagramBuilder;
import org.metasketch.demo.simulator.gui.DEMOEditor;
import org.metasketch.editor.Editor;
import org.metasketch.editor.IProjectBuilder;
import org.metasketch.editor.Project;
import org.metasketch.javafx.graphics.DiagramView;
import org.metasketch.javafx.graphics.JFXDiagram;

public class DEMOProjectBuilder implements IProjectBuilder {

	@Override
	public void buildProject(Editor editor, Project project) {
		DEMOEditor demoEditor = (DEMOEditor) editor;
		DEMOProject demoProject = (DEMOProject) project;

		DiagramView diagramView = demoEditor.getDiagramView();

		// clear all
		diagramView.getTabs().clear();

		// set project

		// open default views
		DEMODiagramBuilder builder = new DEMODiagramBuilder();
		List<JFXDiagram> jfxDiagrams = builder.getDiagrams(demoProject);

		for (JFXDiagram jfxDiagram : jfxDiagrams) {

			Tab tab = new Tab();
			// tab.set
			tab.setText(jfxDiagram.getName());
			tab.setContent(jfxDiagram);
			diagramView.getTabs().add(tab);
			// diagramView.addTab(, jfxDiagram);
		}

	}
}
